<template>
    <a-layout class="main">
        <div class="form">
            <a-button class="formButton" type="primary" @click="getProcessList">查询</a-button>
        </div>
        <a-layout-content>
            <a-table :loading="loading" rowKey="procInsId" :columns="columns" :dataSource="dataSource">
            </a-table>
        </a-layout-content>
    </a-layout>
</template>

<script>
import { myProcessList } from "../../components/process/api/process"
export default {
    data() {
        return {
            dataSource: [],
            columns: [
                {
                    title: "流程编号",
                    dataIndex: "procInsId",
                    key: "procInsId"
                }, {
                    title: "流程名称",
                    dataIndex: "procDefName",
                    key: "procDefName"
                }, {
                    title: "流程分类",
                    dataIndex: "category",
                    key: "category"
                }, {
                    title: "流程版本",
                    dataIndex: "procDefVersion",
                    key: "procDefVersion",
                }, {
                    title: "流程状态",
                    dataIndex: "finishTime",
                    key: "finishTime",
                    customRender: (text) => {
                        if (text === null) {
                            return "未完成"
                        } else {
                            return "已完成"
                        }
                    }
                }
            ],
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                name: null,
                category: null,
                key: null,
                tenantId: null,
                deployTime: null,
                derivedFrom: null,
                derivedFromRoot: null,
                parentDeploymentId: null,
                engineVersion: null
            },
            loading: false
        }
    },
    created(){
        this.getProcessList()
    },
    methods: {
        getProcessList() {
            this.loading = true
            myProcessList(this.queryParams).then(response => {
                console.log(response)
                if (response.code == 200) {
                    this.dataSource = response.data.records;
                } else {
                    this.$message.error(response.msg)
                }
            }).finally(() => {
                this.loading = false
            });
        },
        goPath(record) {
            this.$emit('goPath', { key: 3, record: record });
        }
    }
}
</script>

<style scoped lang="less">
.main {
    width: 1200px;
    margin: auto;
    margin-top: 20px;
    background-color: white;

    .form {
        display: flex;
        justify-content: center;

        .formButton {
            margin: 20px 0;
        }
    }

    .go {
        cursor: pointer;

        &:hover {
            color: #40a9ff;
        }
    }

}
</style>